
<?php
	include 'config.php';

	function clean($text)
{
	$text = strip_tags($text);
	$text = trim($text);
    return ($text); //output clean text
};


	
	$lextitle  = mysqli_real_escape_string($con, clean($_POST['tb_lexTitle']));
	$_SESSION['lextitle'] = $lextitle;
	//$lexdesc = $_POST['tb_lexdesc'];
	$lexcontext = $_POST['context'];
	$lextimedate = date("Y-m-d H:i:s"); 
	$_SESSION['lextimedate']= $lextimedate;
		if (is_array($lexcontext)) {
			foreach($lexcontext as $context){
				$contexts = implode("|", $lexcontext);
					}      
				 };
	$lexskill= $_POST['cb_skill'];
	if (is_array($lexskill)) {
			foreach($lexskill as $skill){
				$skills = implode("|", $lexskill);
					}      
				 };
	$_SESSION['lexcontext'] = $contexts;
	$_SESSION['lexskill'] = $skills;
			
	$query = "INSERT INTO lex (userid, lextitle, lexcontext, lexskill, lextimedate) VALUES ("
	. "'" . $_SESSION['userid']. "',"
	. "'" . $lextitle . "',"
	. "'" . $contexts . "',"
	. "'" . $skills. "',"
	. "'" . $lextimedate. "')";
	echo $query;
	$result = mysqli_query($con,$query) or die ("Could not record lex in database");
	header('LOCATION: lex-files.php'); //go to the next step of the form
	

//description

//user

//skills

//context
?>